<template>
    <div>网站首页{{ $store.state.user }}

        <el-button @click="handleLogout">退出登录</el-button>

    </div>
</template>
<script setup>
import { mockLogout } from '~/api/manager'
import { toast,showModal } from '~/composables/util'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'

const store = useStore()
const router = useRouter()

//import { logout } from '~/api/back/manager'
function handleLogout(){
    showModal("是否要退出登录？").then(res=>{
        mockLogout()
        .finally(()=>{
            store.dispatch("logout")
            // 跳转回登录页
            router.push("/login")
            // 提示退出登录成功
            toast("退出登录成功")
        })
    })
}


</script>
